$(document).ready(function() {
	init();
});

function init() {
	setCmd("led1","on",1);
	setCmd("led1","off",2);
	setCmd("led2","on",3);
	setCmd("led2","off",4);
	setCmd("beep","on",5);
	setCmd("beep","off",6);
	//m0端
	setCmd("m0_led","on",7);
	setCmd("m0_led","off",8);
	setCmd("m0_beep","on",9);
	setCmd("m0_beep","off",10);
	setSegOn("m0_seg","on",11);
	setCmd("m0_seg","off",12);
	setFanOn("m0_fan","on",13);
	setCmd("m0_fan","off",14);
}

function setCmd(key,value,num)
{
	$("#anniu" + num).click(
		function() {
			var str = key + "=" + value;
			$.ajax({
				type:"POST",
				url:"./cgi-bin/ctrl.cgi",
				data:str,
				success:function (data){
					alert(data);
				}
			});	
		}
	)
}

function setSegOn(key,value,num)
{
	$("#anniu" + num).click(
		function() {
			var str = key + "=" + value + $("#Seg").val();
			$.ajax({
				type:"POST",
				url:"./cgi-bin/ctrl.cgi",
				data:str,
				success:function (data){
					alert(data);
				}
			});	
		}
	)
}

function setFanOn(key,value,num)
{
	$("#anniu" + num).click(
		function() {
			var str = key + "=" + value + $("#fan").val();
			$.ajax({
				type:"POST",
				url:"./cgi-bin/ctrl.cgi",
				data:str,
				success:function (data){
					alert(data);
				}
			});	
		}
	)
}